package com.one.consumer.order.ui;

import android.view.View;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.one.common.config.RouterPath;
import com.one.common.utils.StringUtils;
import com.one.common.view.widget.InputLayout;
import com.one.common.view.widget.MyTitleBar;
import com.one.common.view.widget.StepView;
import com.one.consumer.BaseActivityC;
import com.one.consumer.R;
import com.one.common.common.order.extra.ReserveExtra;
import com.one.consumer.reserve.model.item.ReserveItem;
import com.one.consumer.reserve.presenter.ReserveDetailPresenter;
import com.one.consumer.reserve.ui.view.DetailView;

import butterknife.BindView;

/**
 * author ：zhulunjun
 * email  ：zhulunjun@qq.com
 * date   ：2018/10/27 5:06 PM
 * description ：装修 订单详情
 **/
@Route(path = RouterPath.DE_ORDER_DETAIL)
public class DeOrderDetailActivity extends BaseActivityC implements DetailView<ReserveItem> {

    @BindView(R.id.il_no)
    InputLayout ilNo;
    @BindView(R.id.il_time)
    InputLayout ilTime;
    @BindView(R.id.il_type)
    InputLayout ilType;
    @BindView(R.id.il_area)
    InputLayout ilArea;
    @BindView(R.id.il_contact)
    InputLayout ilContact;
    @BindView(R.id.il_phone)
    InputLayout ilPhone;
    @BindView(R.id.il_city)
    InputLayout ilCity;
    @BindView(R.id.il_address)
    InputLayout ilAddress;
    @BindView(R.id.il_price)
    InputLayout ilPrice;
    @BindView(R.id.sv_order)
    StepView svOrder;
    private String[] stepData = {"预约成功", "线下确认", "定金", "尾款", "完成"};

    @Override
    protected void initPresenter() {
        mPresenter = new ReserveDetailPresenter(this, this);
    }

    @Override
    public int getLayoutResId() {
        return R.layout.activity_reserve_detail;
    }

    @Override
    protected void initTitle() {
        super.initTitle();
        getMyTitleBar().setMode(MyTitleBar.Mode.BACK_TITLE)
                .setTitleText("装修订单详情");
    }

    @Override
    public void initView() {
        super.initView();
        svOrder.setData(stepData);
        svOrder.checkIndex(1);
    }

    @Override
    public void setDetail(ReserveItem detail) {
        if (detail != null) {
            ilNo.setText(detail.getOrder_no());
            ilTime.setText(detail.getCreate_time());
            ilArea.setText(detail.getOrder_area());
            ilContact.setText(detail.getContact_name());
            ilPhone.setText(detail.getContact_mobile());
            ilCity.setText(detail.getAddress());
            ilType.setText(detail.getStyle_name());
            ilAddress.setText(detail.getAddress_detail());

            if (detail.getOrder_state().equals(ReserveExtra.STYLE_DY)) {
                ilPrice.setVisibility(View.VISIBLE);
                ilPrice.setText(detail.getOrder_price());
                ilPrice.getTvCenter().setTextColor(getResources().getColor(R.color.text_color_red_DA3924));
            }

            int state = StringUtils.getIntToString(detail.getOrder_state());
            if (state > 0) {
                svOrder.checkIndex(state - 1);
            }
        }
    }

}
